import { createApp } from 'vue'
import { globalRegister } from './global'
import App from './App.vue'
import router from './router'
import store from './store'
import dayjs from 'dayjs'
import { setupStore } from './store/index'
import 'element-plus/lib/theme-chalk/index.css'
import 'normalize.css'
import './assets/css/index.less'
const app = createApp(App)
app.directive('format-time', {
  mounted(el, bindings) {
    let formatString = 'YYYY-MM-DD HH:mm:ss'
    console.log(bindings)
    if (bindings.value) {
      formatString = bindings.value
    }
    const textContent = el.textContent
    let timestamp = parseInt(textContent)
    if (textContent.length === 10) {
      timestamp = timestamp * 1000
    }
    el.textContent = dayjs(timestamp).format(formatString)
  }
})
setupStore()
app.use(store)
app.use(router)
app.use(globalRegister)
app.mount('#app')
